package com.koron.css2.newProjectCenter.impl;

import com.koron.css2.ServerInterface;
import com.koron.css2.newProjectCenter.bean.PjPubUpFlowInventory;
import com.koron.css2.newProjectCenter.mapper.PjPubUpFlowInventoryMapper;
import com.koron.css2.serviceManage.bean.RequestBean;
import com.koron.css2.serviceManage.bean.UserInfoBean;
import com.koron.css2.serviceManage.utils.JsonUtils;
import com.koron.util.Constant;
import org.koron.ebs.mybatis.SessionFactory;
import org.swan.bean.MessageBean;

/**
 * @Author: 苏小龙
 * @CreateTime: 2024-12-04
 * @Description: 工程材料盘点
 * @Version: 1.0
 */
public class PjPubUpFlowInventoryUpdate implements ServerInterface {
    @Override
    public MessageBean<?> exec(SessionFactory factory, UserInfoBean userInfo, RequestBean req) {
        try {
            PjPubUpFlowInventory pubUpInvoice = JsonUtils.objectToPojo(req.getData(), PjPubUpFlowInventory.class);
            PjPubUpFlowInventoryMapper pjPubUpInvoiceMapper= factory.getMapper(PjPubUpFlowInventoryMapper.class);
            // 1. updateTime,updateAccount,updateName
            pubUpInvoice.setUpdateInfo(userInfo);
            // 2. 更新数据
            pjPubUpInvoiceMapper.update(pubUpInvoice);
            // 3. 返回结果
            return MessageBean.create(Constant.MESSAGE_INT_SUCCESS,"工程材料盘点更新成功",null);
        } catch (Exception e) {
            logger.error("工程材料盘点更新失败",e);
            return MessageBean.create(Constant.MESSAGE_INT_FAIL,"工程材料盘点更新失败",null);
        }
    }
}
